package com.gastudio.Protocol;

/**
 * 自定义协议数据包
 * Created by 余艾龙 on 2017/6/21.
 */
public class ProtocolPack {
    private int length;//int 4个字节 Integer.SIZE/8
    private byte flag;//byte 1个字节 Byte.SIZE/8
    private String content;

    public ProtocolPack(byte flag, String content){
        this.flag=flag;
        this.content=content;
        int length_1=content==null?0:content.getBytes().length;
        this.length=(Integer.SIZE/8)+(Byte.SIZE/8)+length_1;
    }

    public String toString(){
        StringBuffer sb=new StringBuffer();
        sb.append("Length:").append(this.length);
        sb.append(" Flag:").append(this.flag);
        sb.append(" Content:").append(this.content);
        return sb.toString();
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public byte getFlag() {
        return flag;
    }

    public void setFlag(byte flag) {
        this.flag = flag;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

}
